﻿using System;
using MyWeb.Business;

namespace MyWeb.Controls
{
    public partial class u_slide_Products : System.Web.UI.UserControl
    {
        private string _lang = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            _lang = Session["Lang"].ToString() != "" ? Session["Lang"].ToString() : "vi";
            if (!IsPostBack)
            {
                ShowPro();
            }
        }
        private void ShowPro()
        {
            var s = "<div class=\"slide-products clearn\">";
            var list = ProductsService.Products_GetByTop("", "Active = '1' and [Index] = '1' and Lang ='" + _lang + "'", "");
            if (list.Count > 0)
            {
                s += "<div class=\"box\"><div id=\"slidePro\"><ul>";
                for (var i = 0; i < list.Count; i++)
                {
                    if(i % 3 == 0)
                    {
                        var chitiet = "/san-pham/" + list[0].GroupProducsId + "/" + list[i].Tag + "/" + list[i].Id + ".html";
                        var download = "/san-pham/" + list[0].GroupProducsId + "/" + list[i].Tag + "/" + list[i].Id + ".html#download";
                        //var download = "/san-pham/" + listgr[0].Tag + "/" + list[i].Id + "-" + list[i].Tag + ".html#download";
                        s += "<li>";
                        s += "<div class=\"sp\"><div class=\"box\">";
                        s += "<div class=\"ImgSP\"><img src='" + list[i].Images + "' /></div>";
                        s += "<div class=\"boxSP\"><ul>";
                        s += "<li><a href=\"#\">Demo</a></li>";
                        s += "<li><a href=\""+ download +"\">Download</a></li>";
                        s += "<li><a href=\""+ chitiet +"\">Chi tiết</a></li>";
                        s += "</ul></div></div></div>";

                    }
                    else if(i % 3 == 2)
                    {
                        var chitiet = "/san-pham/" + list[0].GroupProducsId + "/" + list[i].Tag + "/" + list[i].Id + ".html";
                        var download = "/san-pham/" + list[0].GroupProducsId + "/" + list[i].Tag + "/" + list[i].Id + ".html#download";
                        s += "<div class=\"sp\"><div class=\"box\">";
                        s += "<div class=\"ImgSP\"><img src='" + list[i].Images + "' /></div>";
                        s += "<div class=\"boxSP\"><ul>";
                        s += "<li><a href=\"#\">Demo</a></li>";
                        s += "<li><a href=\"" + download + "\">Download</a></li>";
                        s += "<li><a href=\"" + chitiet + "\">Chi tiết</a></li>";
                        s += "</ul></div></div></div>";
                        s += "</li>";
                    }
                    else
                    {
                        var chitiet = "/san-pham/" + list[0].GroupProducsId + "/" + list[i].Tag + "/" + list[i].Id + ".html";
                        var download = "/san-pham/" + list[0].GroupProducsId + "/" + list[i].Tag + "/" + list[i].Id + ".html#download";
                        s += "<div class=\"sp\"><div class=\"box\">";
                        s += "<div class=\"ImgSP\"><img src='" + list[i].Images + "' /></div>";
                        s += "<div class=\"boxSP\"><ul>";
                        s += "<li><a href=\"#\">Demo</a></li>";
                        s += "<li><a href=\"" + download + "\">Download</a></li>";
                        s += "<li><a href=\"" + chitiet + "\">Chi tiết</a></li>";
                        s += "</ul></div></div></div>";
                    }
                }

                s += "</ul></div></div>";
            }
            s += "</div>";
            ltrslicepro.Text = s;
        }
        #region html code
        /*
         <div class="slide-products clearn">
            <div class="box">
                <div id="slidePro">
                    <ul>
                        <li>
                            <div class="sp">
                                <div class="box">
                                    <div class="ImgSP">
                                        <img src="images/Diem.png" /></div>
                                    <div class="boxSP">
                                        <ul>
                                            <li><a href="#">Demo</a></li>
                                            <li><a href="#">Download</a></li>
                                            <li><a href="#">Chi tiết</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="sp">
                                <div class="box">
                                    <div class="ImgSP">
                                        <img src="images/Diem.png" /></div>
                                    <div class="boxSP">
                                        <ul>
                                            <li><a href="#">Demo</a></li>
                                            <li><a href="#">Download</a></li>
                                            <li><a href="#">Chi tiết</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="sp">
                                <div class="box">
                                    <div class="ImgSP">
                                        <img src="images/Diem.png" /></div>
                                    <div class="boxSP">
                                        <ul>
                                            <li><a href="#">Demo</a></li>
                                            <li><a href="#">Download</a></li>
                                            <li><a href="#">Chi tiết</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="sp">
                                <div class="box">
                                    <div class="ImgSP">
                                        <img src="images/Diem.png" /></div>
                                    <div class="boxSP">
                                        <ul>
                                            <li><a href="#">Demo</a></li>
                                            <li><a href="#">Download</a></li>
                                            <li><a href="#">Chi tiết</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="sp">
                                <div class="box">
                                    <div class="ImgSP">
                                        <img src="images/Diem.png" /></div>
                                    <div class="boxSP">
                                        <ul>
                                            <li><a href="#">Demo</a></li>
                                            <li><a href="#">Download</a></li>
                                            <li><a href="#">Chi tiết</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="sp">
                                <div class="box">
                                    <div class="ImgSP">
                                        <img src="images/Diem.png" /></div>
                                    <div class="boxSP">
                                        <ul>
                                            <li><a href="#">Demo</a></li>
                                            <li><a href="#">Download</a></li>
                                            <li><a href="#">Chi tiết</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="sp">
                                <div class="box">
                                    <div class="ImgSP">
                                        <img src="images/Diem.png" /></div>
                                    <div class="boxSP">
                                        <ul>
                                            <li><a href="#">Demo</a></li>
                                            <li><a href="#">Download</a></li>
                                            <li><a href="#">Chi tiết</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="sp">
                                <div class="box">
                                    <div class="ImgSP">
                                        <img src="images/Diem.png" /></div>
                                    <div class="boxSP">
                                        <ul>
                                            <li><a href="#">Demo</a></li>
                                            <li><a href="#">Download</a></li>
                                            <li><a href="#">Chi tiết</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="sp">
                                <div class="box">
                                    <div class="ImgSP">
                                        <img src="images/Diem.png" /></div>
                                    <div class="boxSP">
                                        <ul>
                                            <li><a href="#">Demo</a></li>
                                            <li><a href="#">Download</a></li>
                                            <li><a href="#">Chi tiết</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
         */
        #endregion
    }
}